package com.dhcc.bpm.modules.content.controller;

import io.swagger.annotations.Api;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;

import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.content.entity.OperationTrack;
import com.dhcc.bpm.modules.content.vo.OperationTrackVO;
import com.dhcc.bpm.modules.content.service.IOperationTrackService;
import org.springblade.core.boot.ctrl.BladeController;

/**
 * 操作日志表 控制器
 *
 * @author cdh
 * @since 2021-12-08
 */
@RestController
@AllArgsConstructor
@RequestMapping("bpm-content/operationtrack")
@Api(value = "操作日志表", tags = "操作日志表接口")
public class OperationTrackController extends BladeController {

	private IOperationTrackService operationTrackService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入operationTrack")
	public R<OperationTrack> detail(OperationTrack operationTrack) {
		OperationTrack detail = operationTrackService.getOne(Condition.getQueryWrapper(operationTrack));
		return R.data(detail);
	}

	/**
	 * 分页 操作日志表
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入operationTrack")
	public R<IPage<OperationTrack>> list(OperationTrack operationTrack, Query query) {
		IPage<OperationTrack> pages = operationTrackService.page(Condition.getPage(query), Condition.getQueryWrapper(operationTrack));
		return R.data(pages);
	}

	/**
	 * 自定义分页 操作日志表
	 */
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入operationTrack")
	public R<IPage<OperationTrackVO>> page(OperationTrackVO operationTrack, Query query) {
		IPage<OperationTrackVO> pages = operationTrackService.selectOperationTrackPage(Condition.getPage(query), operationTrack);
		return R.data(pages);
	}

	/**
	 * 新增 操作日志表
	 */
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入operationTrack")
	public R save(@Valid @RequestBody OperationTrack operationTrack) {
		return R.status(operationTrackService.save(operationTrack));
	}

	/**
	 * 修改 操作日志表
	 */
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入operationTrack")
	public R update(@Valid @RequestBody OperationTrack operationTrack) {
		return R.status(operationTrackService.updateById(operationTrack));
	}

	/**
	 * 新增或修改 操作日志表
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes = "传入operationTrack")
	public R submit(@Valid @RequestBody OperationTrack operationTrack) {
		return R.status(operationTrackService.saveOrUpdate(operationTrack));
	}


	/**
	 * 删除 操作日志表
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 8)
	@ApiOperation(value = "删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(operationTrackService.removeByIds(Func.toLongList(ids)));
	}


}
